Skip to content

Decode Verisense SR68/SR61 GSR against its 0.4986 V amplifier reference - #312

Merged
JongChern merged 1 commit into
masterfrom
gsr_verisense_amplifier_reference
Oct 1, 2026
Merged

JongChern merged 1 commit into
masterfrom
gsr_verisense_amplifier_reference

Conversation

@marknolan

Copy link
Copy Markdown
Member

Stacked on #307 (DEV-1070), which is stacked on #305 (DEV-1067). It targets the DEV-1070 branch, so the diff is this change only.

Explainer: before/after charts for DEV-1067, DEV-1068 and DEV-1070, the sibling PRs, and the GSR resistor table per hardware model: https://claude.ai/artifact/6hDc2Ue9hdF8gcUDZXzFts (Shimmer sign-in)

Problem

The Verisense SR68 and SR61-5/6 GSR front end biases its amplifier from a 261k/100k divider off the 1.8 V rail: 1.8 × 100 / 361 = 0.4986 V. The hardware designer confirmed the divider, and it is the same on every Verisense revision that has this front end. The decode divided by the Shimmer3's 0.5 V instead.

  • Every resistance read about 0.5–1% high. A real 2.7 MΩ load (DEV-793 B4d, median code ~1850 on range 3) read 2778 kΩ. With the right reference it reads 2758 kΩ, closer to the load.
  • An open circuit read about 4.0 GΩ rather than 541 MΩ. Both are well below 0.03 µS, so connectivity was right either way.
  • The C# API, ASM_BaseStation and the web SDK already divide by 0.4986 V, so Java was the one host API that disagreed.

Fix

  • SensorGSR gains a per-front-end amplifier reference, currentGsrAmplifierRefVoltage, beside the resistors and the open-circuit limit. It defaults to GSR_AMPLIFIER_REF_VOLTAGE (0.5 V).
  • SensorGSRVerisense sets VERISENSE_PULSE_PLUS_GSR_AMPLIFIER_REF_VOLTAGE (the divider value) for the SR68 and the SR61, the same place it sets their resistors.
  • The static calibrateGsrDataToKOhmsUsingAmplifierEq, calibrateGsrDataToKOhmsWithOpenCircuitLimit and uncalibrateGsrDataTokOhmsUsingAmplifierEq keep their signatures, at 0.5 V, and gain overloads that take the reference. The Shimmer3, ShimmerGQ and SR62 paths are unchanged, and so are outside callers: the only one found is Shimmer-Advance-API's EmulatorShimmerGq, which uses Shimmer3 values.
  • The range-3 open-circuit limit stays 1138, the value the C# API and the web SDK use. It clears the corrected reference (code 1134.3). The codes it now also moves, 1135–1137, decode to 0.7–3.0 GΩ on range 3, an open circuit either way.

Tests

Test Change
API_00015 test005 was "the limit is the first code above the reference"; now "clears the reference, as 1134 did not, and is the first code above 0.5 V"
API_00015 test006 (new) the reference is the divider value, and the SR68-9 and SR61-5 get it while the SR62 keeps 0.5 V
API_00015 test007 (new) the B4d 2.7 MΩ load decodes as the C# API and web SDK decode it, and closer to 2.7 MΩ than 0.5 V put it
API_00019 test002 codes below the limit must decode negative or above the top of range 3, since 1135–1137 now sit above the reference
Build Result
this PR with the setCurrentGsrAmplifierRefVoltage line removed 4 of the 16 GSR tests fail
this PR the whole ShimmerDriver suite passes (119 tests)

CI builds only ShimmerDriverPC, so it will not run these tests. They were run locally.

After merge

  • ASM_PC: every gen-2 (SR68/SR61) GSR_CAL value moves by about 0.5–1%, so its GSR reference files for gen-2 recordings (Test_056 and any others) need regenerating after the submodule bump. DEV-1070: decode a GSR code below the reference as open on every range #307 already requires regenerating Test_056's; doing both at once after all three PRs merge avoids regenerating twice.
  • Shimmer-MATLAB-ID: its vendored VerisenseFileParserPC.jar gets this only when re-vendored.

Sibling APIs

None need this change:

  • C# API (ShimmerBLEAPI/Sensors/SensorGSR.cs) and ASM_BaseStation (both SensorGSR copies): already 0.4986 V.
  • web SDK (SensorADC): already 0.4986 V.
  • SwiftAPI: Shimmer3 only, 0.5 V is right.
  • pyshimmer: reports GSR raw only.

🤖 Generated with Claude Code

The SR68 and SR61-5/6 GSR front end biases its amplifier from a 261k/100k
divider off the 1.8 V rail: 1.8 x 100 / 361 = 0.4986 V, confirmed by the
hardware designer, and the same on every Verisense revision that has the
front end. The decode divided by the Shimmer3's 0.5 V instead, so every
resistance read about 0.5-1% high (a real 2.7 MOhm load, DEV-793 B4d, read
2778 kOhm rather than 2758) and an open circuit about 4.0 GOhm rather than
541 MOhm. The C# API and the web SDK already divide by 0.4986 V.

SensorGSR gains a per-front-end amplifier reference beside the resistors and
the open-circuit limit, defaulting to 0.5 V; SensorGSRVerisense sets the
divider value for the SR68 and SR61. The static decode methods keep their
signatures, at 0.5 V, and gain overloads that take the reference, so the
Shimmer3, ShimmerGQ and SR62 paths, and outside callers such as the GQ
emulator in Shimmer-Advance-API, are unchanged.

The range-3 open-circuit limit stays 1138, the value the C# API and the web
SDK use. It clears the corrected reference (code 1134.3), and the codes it
now also moves, 1135-1137, decode to 0.7-3.0 GOhm, an open circuit either
way. API_00015 and API_00019 are updated for that, and API_00015 gains a
check on the reference and on the B4d load.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Base automatically changed from DEV-1070_gsr_below_reference_reads_open to master October 1, 2026 05:24
@JongChern
JongChern self-requested a review October 1, 2026 05:45
@JongChern

Copy link
Copy Markdown
Contributor

ok looks good

@JongChern
JongChern merged commit 968f92d into master Oct 1, 2026
@JongChern
JongChern deleted the gsr_verisense_amplifier_reference branch October 1, 2026 05:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants